<script setup>
// const emit = defineEmits(['getid'])
// export default {}
defineProps({
  image: {
    type: String
  },
  name: {
    type: String
  },
  description: {
    type: String
  },
  sellerName: {
    type: String
  },
  price: {
    type: Number
  },
  categoryName: {
    type: String
  },
  id: { type: String }
})
// const sendmsg = () => {
//   emit('getid')
// }
</script>
<template>
  <div class="goods-item">
    <div class="left">
      <img
        id="myImage"
        v-if="image"
        :src="image || '/assets/empty.png'"
        alt=""
      />
      <img id="myImage" v-else src="@/assets/empty.png" alt="" />
    </div>
    <a
      :href="`/goods/detail/${id}`"
      target="_blank"
      rel="noopener noreferrer"
      class="right"
      style="text-decoration: none"
    >
      <span class="name">商品名称：{{ name }}</span>
      <span class="tittext-ellipsis-2"
        >详情介绍:
        {{ description }}
      </span>
      <span class="sellerName">商家:{{ sellerName }}</span>
      <div class="price">
        <span class="newprice">价格:{{ price }}元</span>
        <span class="categoryName">分类：{{ categoryName }} </span>
        <!-- <el-button class="anniu">查看详情</el-button> -->
      </div>
    </a>
  </div>
</template>
<style lang="scss" scoped>
.goods-item {
  img {
    height: 200px;
    width: 200px;
  }
  width: 30%;
  height: 220px;
  margin: 6px;
  padding: 15px;
  box-shadow: 0px 0px 1px 1px gray;
  background-color: #fff;
  display: flex;
  .left {
    width: 50%;
    img {
      display: block;
      width: 100%;
      height: 100%;
    }
  }
  .right {
    flex: 1;
    font-size: 13px;
    line-height: 1.3;
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    .tittext-ellipsis-2 {
      max-width: 100px;
      max-height: 80px;
      max-width: 100%; /* 设置最大宽度 */
      overflow: hidden; /* 隐藏超出部分 */
      text-overflow: ellipsis; /* 使用省略号表示溢出 */
      // white-space: nowrap; /* 防止文本换行 */
    }
    .name {
      color: rgb(16, 15, 15);
      font-size: 15px;
    }
    .sellerName {
      color: #999;
      font-size: 12px;
    }
    .price {
      color: #999;
      font-size: 16px;
      .newprice {
        color: #f03c3c;
        margin-right: 10px;
      }
      .categoryName {
        font-size: 12px;
      }
      // .anniu {
      // }
      :hover {
        background-color: darkturquoise;
      }
    }
  }
}
</style>
